<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Contact extends MY_Controller
{

    public function __construct()
    {
        parent::__construct();
        $this->layout->setLayout('frontend/index');
    }

    public function index(){
        $data['check'] = false;
        if (isset($_POST['submit']) and $_POST['submit'] == 'send'){
            $name = $this->input->post('name');
            $email = $this->input->post('email');
            $subject = $this->input->post('subject');
            $message = $this->input->post('message');
            $content = "Hi, <b>".$name. "</b>, Thank you for taking the time to provide your comments on our service. Petshop believes that customer satisfaction is of paramount importance to our business. We always welcome your views and suggestions on how we can serve you better. Your comments will be read by our global and local service departments so we can continue excellent work or improve performance if needed.<br/>";
            $content .= "We thank you very much for your valuable feedback. </b><br/><br/>";
            $content .= "<b>Petshop </b><br/>";
            $content .= "Phone: 0906371118";
            $feedback_data = array(
                'name' => $name,
                'email' => $email,
                'subject' => $subject,
                'message' => $message
            );
            if($this->mfeedback->create($feedback_data))
            {
                $data['check'] = true;
            }
            $mail = array(
                "to_receiver" => $email,
                "message" => $content,
                "subject" => "Thank you for your feedback, PetShop"
            );
            $this->email->config($mail);
            $this->email->sendmail();
        }
        $this->layout->view('frontend/contact', $data);
    }
}